<!--系统消息页面body部分-->
<div class="regi_container">
<div id="regi_container" class="radius">
	<div id="regi_row_1">
		<h1 class="regi_title">提交汇款信息</h1>
		<form action="<?php echo site_url('Moneychange/RemittancePost') ?>" method="POST" id="post_form">
		<ul class="regi_account">
        	<li class="regi_errer"></li>
			<li>
				<span>收款方式：</span>
                <div class="regi_input">
					<?php 
					$options = array(
						'0'=>'请选择'
					);
					foreach($PayTypes->result() as $row)
					{
						$options[$row->Id] = $row->Name;
					}			
					echo form_dropdown('BelongPayType', $options, set_value('BelongPayType'),"id='BelongPayType'");
					?>BelongPayType
				</div>
			</li>
        	<li> 
                <span>汇款金额：</span>
                <div class="regi_input">
					<?php echo form_input('Remittance',set_value('Remittance'),"placeholder='汇款金额'  class='input-xlarge' onkeyup='Calculate(this)'");?>马币Remittance
					<span style="width:200px"><?php echo @$Remittance_Error;?></span>
				</div>
	    	</li>
			<script>
			function PayType(){
				var json = <?php echo json_encode($PayTypes->result());?>;
				return json;
			}
			
			function GetFeeCalculateType(id1){
				json  = PayType();
				ret = {};
				for(i=0;i<json.length;i++){
					if(json[i]['Id']==id1){
						ret = {'Fee':json[i]['Fee'],'CalculateType':json[i]['CalculateType'],'MaybeTime':json[i]['MaybeTime']};
					}	
				}
				return ret;
			}
			function Calculate(o){
				/*
				马币到人民币计算
				马币*汇率-手续费
				人民币到马币计算
				人民币+手续费/汇率
				*/	
				var exchange = 1.95;//汇率
				var inpay = parseFloat(o.value);//输入金额
				var payTypeId = $('#BelongPayType')[0].value;
				var fee = parseFloat(GetFeeCalculateType(payTypeId)['Fee']);//手续费
				var CalculateType = GetFeeCalculateType(payTypeId)['CalculateType'];//手续费计算方式
				var ReceiptAmount = $('#ReceiptAmount')[0];
				var MaybeTime = $('#MaybeTime')[0];
				
				if(CalculateType=='Add'){//直接金额模式
					v = inpay * exchange - fee;//计算总计
					ReceiptAmount.value = Math.round(v*100)/100;//inpay * exchange - fee;//计算总计
				}	
				else{//百分比模式
					v = (inpay * exchange) - (inpay * exchange)*(fee/100);//计算总计
					ReceiptAmount.value = Math.round(v*100)/100;//(inpay * exchange) - (inpay * exchange)*(fee/100);//计算总计
				}
				
				MaybeTime.value= GetFeeCalculateType(payTypeId)['MaybeTime'];
			}
			</script>
        	<li> 
                <span>手机号码：</span>
                <div class="regi_input">
					<?php echo form_input('Mobile',set_value('Mobile'),"placeholder='手机号码'  class='input-xlarge'");?>Mobile
					<span style="width:200px"><?php echo @$Mobile_Error;?></span>
				</div>
	    	</li>
        	<li> 
                <span>收款账号：</span>
                <div class="regi_input">
					<?php echo form_input('AccountNo',set_value('AccountNo'),"placeholder='填写支付宝或银行账号'  class='input-xlarge'");?>AccountNo
					<span style="width:200px"><?php echo @$AccountNo_Error;?></span>
				</div>
	    	</li>
        	<li> 
                <span>开户姓名：</span>
                <div class="regi_input">
					<?php echo form_input('Name',set_value('Name'),"placeholder=''  class='input-xlarge'");?>Name
					<span style="width:200px"><?php echo @$Name_Error;?></span>
				</div>
	    	</li>
			<li>---------------------------------------------------------------------------------------</li>

			<li>
				<span>汇款凭据：</span>
                <div class="regi_input">
				<input type="file" name="userfile" size="20" />请上传汇款图片
				</div>
			</li>
        	<li> 
                <span>收款金额：</span>
                <div class="regi_input">
					<?php echo form_input('ReceiptAmount',set_value('ReceiptAmount'),"placeholder=''  class='input-xlarge' readonly id='ReceiptAmount'");?>ReceiptAmount
					<span style="width:200px"><?php echo @$ReceiptAmount_Error;?></span>
				</div>
	    	</li>
        	<li> 
                <span>到账时间：</span>
                <div class="regi_input">
					<?php echo form_input('MaybeTime',set_value('MaybeTime'),"placeholder=''  class='input-xlarge' readonly id='MaybeTime'");?>秒MaybeTime
					<span style="width:200px"><?php echo @$MaybeTime_Error;?></span>
				</div>
	    	</li>
        	<li>
			<button type="submit"  class="btn btn-large btn-primary" onclick="sumbit1()">提交汇款信息</button>
			</li>
		</ul>
   		</form>
    </div>
    <div id="regi_row_2">
		<ul>
			<li><img src='http://pic1a.nipic.com/2009-01-04/200914173641218_2.jpg'/></li>
		</ul>
	</div>
	<div style="clear:both;"></div>
    </div>
</div>
<div>

</div>
<!-- Javascript for this page. -->
<script type="text/javascript">
    function TWinOpen(url,id,iWidth,iHeight)
    {
        var iTop = (screen.height-30-iHeight)/2; //获得窗口的垂直位置;
        var iLeft = (screen.width-10-iWidth)/2; //获得窗口的水平位置;
        TWin=window.showModalDialog(url,null,"dialogWidth="+iWidth+"px;dialogHeight="+iHeight+"px;dialogTop="+iTop+"px;dialogLeft="+iLeft+"px");
    }

    function iFrameHeight(frame) {   
        var ifm= $(frame);
        var subWeb = document.frames ? document.frames[frame].document : ifm.contentDocument;   
        if(ifm != null && subWeb != null) {
            ifm.height = subWeb.body.scrollHeight;
        }   
    }
</script>
